package com.sharkburner.aeris.ui.module.article.component;

import org.springframework.stereotype.Component;

import com.sharkburner.aeris.dao.entity.Article;
import com.sharkburner.common.listener.GridViewListener;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Link;
import com.vaadin.ui.VerticalLayout;

/**
 * 
 * @author piu
 * 
 */
@Component
public class ArticleGridListView implements GridViewListener<Article> {

    @Override
    public AbstractComponent renderObject(Article article) {
	VerticalLayout articleCol = new VerticalLayout();
	articleCol.setWidth("50.0%");

	Link link = new Link();
	link.setCaption(article.getName());
	link.setResource(new ExternalResource(article.getLink()));
	link.setTargetName("_blank");

	articleCol.addComponent(link);

	return articleCol;
    }

}
